import BasePrompt from "@/components/BasePrompt.vue"
import Vue from 'vue'

let Alert = Vue.extend(BasePrompt)
let instance
const install = () => {
    Object.defineProperty(Vue.prototype, '$alert', {
        get() {
            const alertMsg = options => {
                options = {
                    txt: options
                }
                instance = new Alert({
                    data: options
                })
                instance.vm = instance.$mount()
                document.body.appendChild(instance.vm.$el)
                Vue.nextTick(() => {
                    instance.show = true
                })
                return instance.vm
            }
            return alertMsg
        }
    })
}

export default install